//解释说明弹窗
//<script src="./js/custom_dialog.js"></script>
//弹窗数据
// var data = {
//     title:"ROI名词说明",
//     subTitle:"ROI：1块钱成本带来的活动收益",
//     infoList:["ROI高于6：表明营销活动成功，高于同行业90%的商家","ROI高于6：表明营销活动成功，高于同行业90%的商家","ROI高于6：表明营销活动成功，高于同行业90%的商家","ROI高于6：表明营销活动成功，高于同行业90%的商家"]
// }
//关闭回调
// var close = function(){

// }
// explanationDialog({data:data,callback:close})

function explanationDialog(param) {
  var dialogTitle = "<h3 class='title'>"+param.data.title+"</h3><h4 class='subheading'>"+param.data.subTitle+"</h4>";
  var dialogInfoList = "";
  param.data.infoList.map(function(items,index){
    dialogInfoList +="<li><span>•</span><p>"+items+"</p></li>"
  })
  var dialogBox = "<div class='dialogBoxExplanation'><div class='layer'></div><div class='content'><span class='zhk-alert_close close'></span>"+dialogTitle+"<ul class='infoList'>"+dialogInfoList+"</ul></div></div>";
  $('body').append(dialogBox);
  var contentHeight = $('.dialogBoxExplanation .content').height();
  $('.dialogBoxExplanation .content').css({top:($(document).height()-contentHeight)/2});
  var $parent = $('.dialogBoxExplanation');
  $parent.on("click", '.close', function() {
    $parent.off();
    $parent.remove();
    param.callback && param.callback();
  });
}
//优惠券设置弹窗
//有图片的传src
//     var data = [
//     {title:"商品名称",info:"鱼香肉丝，我是一条超长的商品名称我是一条超长的商品名称"},
//     {title:"商品名称",src:"dfsf"},
//     {title:"超过六位商品名称",info:"2017-01-01  至 2017-01-31"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     {title:"商品名称",info:"我是一条超长的商品名称我"},
//     ]
// var close = function(){

// }
// couponSetDialog({data:data,callback:close})
function couponSetDialog(param) {
    var dialogInfoList = "";
    param.title = param.title || "优惠券";
    param.data.map(function (items, index) {
        var info = !items.src ? items.info : "<img src='" + items.src + "' />"
        dialogInfoList += "<li><span>" + items.title + "</span><p>" + info + "</p></li>"
    });
    var dialogBox = "<div class='couponSetDialog'><div class='layer'></div><div class='content'><span class='zhk-alert_close close'></span><h3 class='title'>" + param.title + "</h3><ul class='infoList'>" + dialogInfoList + "</ul></div></div>";
    $('body').append(dialogBox);
    var contentHeight = $('.couponSetDialog .content').height();
    $('.couponSetDialog .content').css({top: ($(document).height() - contentHeight) / 2});
    var $parent = $('.couponSetDialog');
    $parent.on("click", '.close', function () {
        $parent.off();
        $parent.remove();
        param.callback && param.callback();
    });
}

//机具详情弹窗
//var data={type:"",facilityNum:"",store:"",versions:"",orderNum:"",logistics:"",logisticsNum:""}
//type:机具类型,facilityNum:设备序列号,store:所属门店,versions:门店版本,orderNum:订单编号,logistics:物流公司,logisticsNum:物流单号
function machinesDialog(param){
  var wl=param.data.logistics?"<li><span class='label'>物流公司</span><span class='info'>"+param.data.logistics+"</span></li>"+
  "<li><span class='label'>物流单号</span><span class='info'>"+param.data.logisticsNum+"</span></li>":"";
  var list = "<li><span class='label'>机具类型</span><span class='info'>"+param.data.type+"</span></li>"+
  "<li><span class='label'>设备序列号</span><span class='info'>"+param.data.facilityNum+"</span></li>"+
  "<li><span class='label'>所属门店</span><span class='info'>"+param.data.store+"</span></li>"+
  "<li><span class='label'>订单编号</span><span class='info'>"+param.data.orderNum+"</span></li>"+
  "<li class='split'></li>"+wl;
  var dialogBox = "<div class='machinesDialog'><div class='layer'></div><div class='content'><span class='zhk-alert_close close'></span><h3 class='title'>机具详情</h3><ul class='infoList'>"+list+"</ul></div></div>";
  $('body').append(dialogBox);
  var contentHeight = $('.machinesDialog .content').height();
  $('.machinesDialog .content').css({top:($(document).height()-contentHeight)/2});
  var $parent = $('.machinesDialog');
  $parent.on("click", '.close', function() {
    $parent.off();
    $parent.remove();
    param.callback && param.callback();
  });

}
